<template>
  <div class="page-style">
    <returning-btn @download="downloadFun" />
    <returning-tab :table-data="tabData" />
    <pagination :total="total" @pagination="currentPageSize" />
  </div>
</template>

<script>
import returningBtn from './components/returning/returning-btn'
import returningTab from './components/returning/returning-tab'
import pagination from '@/components/Pagination'
import { getReturnOrderList } from '@/api/wms'
export default {
  components: {
    returningBtn,
    pagination,
    returningTab
  },
  data() {
    return {
      total: 0,
      p: 1,
      num: 10,
      tabData: []
    }
  },
  created() {
    this.getReturnOrderList()
  },
  methods: {
    currentPageSize(val) {
      console.log(val)
    },
    getReturnOrderList() {
      const data = {
        p: this.p,
        num: this.num
      }
      getReturnOrderList(data).then(res => {
        console.log(res)
        this.total = Number(res.count)
        this.tabData = res.list
      })
    },
    downloadFun() {
      import('@/vendor/Export2Excel').then(excel => {
        const data = []
        const Theader = ['入库单号', '入库时间', '仓库名称', '总数量', '大条码数', '中条码数', '小条码数', '上传账号']
        this.tabData.forEach(item => {
          data.push([item.order_num, item.order_date, item.warehouse_content.warehouse_name, item.count_all_num, item.big_bar_code_num, item.in_bar_code_num, item.small_bar_code_num, item.bar_code_user_content.name])
        })
        excel.export_json_to_excel({
          filename: '退货列表',
          data,
          header: Theader,
          autoWidth: true,
          bookType: 'xlsx'
        })
      })
    }
  }
}
</script>

<style lang="sass" scoped>

</style>
